import java.util.List;
import java.util.LinkedList;

class ConDiaCClass{
    private List<EBNFClass> ebnfs;
    private List<GLCClass> glcs;
    private List<Operation> operations;

    public ConDiaCClass(){
		this.ebnfs=new LinkedList<EBNFClass>();
		this.glcs=new LinkedList<GLCClass>();
		this.operations=new LinkedList<Operation>();
    }

    public ConDiaCClass(List<EBNFClass> ebnfs, List<GLCClass> glcs, List<Operation> operations){
		this.ebnfs=ebnfs;
		this.glcs=glcs;
		this.operations=operations;
    }

    public List<EBNFClass> getEBNFs(){
		return this.ebnfs;
    }

    public List<GLCClass> getGLCs(){
		return this.glcs;
    }

    public List<Operation> getOperations(){
		return this.operations;
    }

    public void addEBNF(EBNFClass e){
		this.ebnfs.add(e);
    }

    public void addGLC(GLCClass g){
		this.glcs.add(g);
    }

    public void addOperation(Operation o){
		this.operations.add(o);
    }

    public void addOperations(ConDiaCClass cdc){
		for(int i=0;i<cdc.getOperations().size();i++)
		    this.operations.add(cdc.getOperations().get(i));
   	 }

    public void GLC2EBNF(String id){
	int indice=-1;
	for(int i=0;i<glcs.size();i++){
	    if(glcs.get(i).getId().equals(id)){
		indice=i;
	    }
	}
	
	if(indice!=-1){
	    EBNFClass e = new EBNFClass(id);
	    for(int i=0;i<glcs.get(indice).getSimbols().size();i++)
		e.addSimbol(glcs.get(indice).getSimbols().get(i));
	    
	    for(int i=0;i<glcs.get(indice).getSintaxRule().size();i++)
		e.addSR(glcs.get(indice).getSintaxRule().get(i).GLC2EBNF());				
	    
	    addEBNF(e);
	    //		e.setSR(glcs.get(indice).GLC2EBNF())
	}
	
	//	return glcs.get(indice).GLC2EBNF();
	
    }
    
    public String toString(){
	String s="";
	for(int i=0;i<ebnfs.size();i++)s+=ebnfs.get(i).toString();
	for(int i=0;i<glcs.size();i++)s+=glcs.get(i).toString();
	
	return s;
    }
}
